﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace 正则表达式学习工具
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string testRegex, testText, testResult,testReplace;
            
            testRegex = rtbRegex.Text;
            testText = rtbText.Text;
            testReplace=rtbReplace.Text;
            testResult = Regex.Replace(testText, testRegex, testReplace);

            rtbResult.Text = testResult;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string strHelp = string.Empty;
            strHelp += "$&  整个表达式匹配的文本等效于$0\n";
            strHelp += "$1,$2...  对应相应的分组匹配内容\n";
            strHelp += "$(name)  对应相应的命名分组匹配\n";
            strHelp += "$`  目标字符串中匹配文本之前的内容\n";
            strHelp += "$´  目标字符串中匹配文本之后的内容\n";
            strHelp += "$$  单个$符号\n";
            strHelp += "$_  整个原始目标字符串的副本\n";
            strHelp += "$+  不常用，匹配正则表达式中最靠后的捕获括号中的内容\n";

            MessageBox.Show(strHelp);
        }


    }
}
